package longcaisuyun.longcai.com.yiliubabalongcaisuyun;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import longcaisuyun.longcai.com.suyunbean.HaoPingPaiHangBang;



/**
 * Created by Administrator on 2016/2/19.
 */
public class HaoPingAdapter extends BaseAdapter {
    Context context;
    ViewHolder vh;
    HaoPingPaiHangBang haoPingPaiHangBang;

    public HaoPingAdapter(Context context, HaoPingPaiHangBang haoPingPaiHangBang) {
        this.context = context;
        this.haoPingPaiHangBang = haoPingPaiHangBang;
    }

    public int getCount() {
        return haoPingPaiHangBang.getList().size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            vh = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_paihang, null);
            MyApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);
            vh.b = (Button) convertView.findViewById(R.id.b_num);
            vh.tv_1 = (TextView) convertView.findViewById(R.id.tv_name);
            vh.tv_2 = (TextView) convertView.findViewById(R.id.tv_num);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }
        vh.tv_1.setText(haoPingPaiHangBang.getList().get(position).getUsername());
        vh.tv_2.setText(haoPingPaiHangBang.getList().get(position).getNumber());
        vh.b.setText(String.valueOf(position+1));
        return convertView;
    }

    class ViewHolder {
        public Button b;
        public TextView tv_1;
        public TextView tv_2;
    }
}
